﻿<!doctype html>
<html>
<!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>储值明细</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/common.js"></script>
<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery.pager.js"></script>
<script type="text/javascript" src="../js/gbRst.js"></script>
<link href="../css/style.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/shop.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script>
<script type="text/javascript" src="../js/pagination.js"></script>
<script type="text/javascript" src="../js/dataTable.js"></script>
<script type="text/javascript" src="../js/find.js"></script>
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script type="text/javascript" >

var pagecount = 0;
var count = 0;
var shopId="shopId";

$(function(){
	$("#dtBegin").val(getToday())
	$("#dtEnd").val(getToday())
})
function InitTables(pageIndex,shopId) {
	var code=$("#code").val().replace(/\s/gi,'');
	var billNo=$("#billNo").val().replace(/\s/gi,'');
	var startDate=$("#dtBegin").val().replace(/\s/gi,'');
	var endDate=$("#dtEnd").val().replace(/\s/gi,'');
	var shopId="";
	if($("#shopIsChoosed").is(":checked")){	
		shopId=$("#shopID").val();
		
		if(shopId!=""&&shopId!=null){
		}else{
			shopId = ""
		}
	}
	var mp = $("#mp").val();
	
	new Pagination({
		url : '../memberDepositBill/find/shopId/5/params',
		data : {
			shopId : shopId,
			startDate : startDate,
			endDate : endDate,
			memberCardNo : code,
			mp:mp
		},
		success : printDataToPage,
		pageSize : 10
	});
	
	var param={'shopId':shopId,'startDate':startDate,'endDate':endDate,'memberCardNo':code,'mp':mp}
	$.ajax({
		type : "get",
		async:false,
		data :param,
		datatype : "json",
		url : "../memberDepositBill/find/memberDepositBillListSum",
		success : function(data) {
			var rst = JSON.parse(data);
						
					var obj = DealAndShowMsg(data,false,false);
					if(rst.state==0){
					if(rst.result.data[0][0]>=0){
					 	$("#sum").html("储值总计："+getHtmlInt(rst.result.data[0][0])+"元    "+"赠送总计："+getHtmlInt(rst.result.data[0][1])+"元"+"  实际总计："+getHtmlInt(rst.result.data[0][2])+"元");	

					}else{
					 	$("#sum").html("");	

					}
						
					}
					
					
		}	
	});
		
	
}


function printDataToPage(message) {
	dataTable({
		tbodyId : 'membersDatail',
		 heads : ["ShopName", "BillNo", "CreateFileTime", "memberCard", "custName", "mp", "IsDpAdjustment", "Amount","gotDeposit","sum","CreateFileMan","Paid","ID"],
		rst : message,
		sup : {
			id : "sup",
			template : "共 [index] 条"
		},
		handler : [{
			col : 11,
			f : paid
		},{
			col : 6,
			f : IsDpAdjustment
		}],
		trGender:trGenders
	});
}

function IsDpAdjustment(heads, row){
	var storedType = "";
	if(IsNotEmpty(heads)){
		if(heads == 1){
			storedType = "储值变动";
		}else{
			storedType = "会员储值";				
		}
	}else{
		storedType = "会员储值"
	}
	return storedType;
}

function trGenders(row){
	if(IsNotEmpty(row)){
		return "<tr id='Ids"+row+"' ></tr>";
	}
}

function paid(heads, row) {
	var paidName = "";
	if(IsNotEmpty(heads)){
		if(heads == 0){
			paidName = "未付";
		}else{
			paidName = "已付";				
		}
	}
	return paidName;
}

PageClick = function(pageclickednumber) {
    $("#pager").pager({ pagenumber: --pageclickednumber, pagecount: pagecount, buttonClickCallback: PageClick });
    $("#result").html("Clicked Page " + pageclickednumber);
	InitTables(pageclickednumber,shopId);
}

function search(){
	InitTables(0);
}

function initTable(json){
	if(json!=null && json.state==0){
		var params = new Array("ShopName", "BillNo","memberCardNo","CustomerName","mp","ConsumeNum","Amount", "CreateFileTime", "BillFrom");// "PayCash", "PayPos", "PayDepstAmt", "PayCheck", "PayPersonCard", "PayIntAmtMny", "StaName", "PaidName"
		Loadtable(json,params,"memberList");
	}
}


function Loadtable(json, params, tableId){
	var phArray = new Array();
	var count = 0;
	if (params != null) {
		$(params).each(function(pIndex, pData) {
			$.each(json.result.head, function(hIndex, hData) {
				if (pData == hData) {
					phArray[count++] = hIndex;
				}
			});
		});
	}
	if (json.result.data != null) {
		$.each(json.result.data, function(index, dt) {
			$("table[id='" + tableId + "']").append("<tr></tr>");
			$(phArray).each(function(phIndex, data) {
				$.each($(dt), function(dtIndex, d) {
					if (dtIndex == data) {
						$("table[id='" + tableId + "'] tr:last").append("<td>" +  (d === null||d == "null" ? " " : d) + "</td>");
					}
				});
			});
		});
		
	}
	
}

function  downRescouse(){
	var code=$("#code").val().replace(/\s/gi,'');
	var billNo=$("#billNo").val().replace(/\s/gi,'');
	var dtBegin=$("#dtBegin").val().replace(/\s/gi,'');
	var dtEnd=$("#dtEnd").val().replace(/\s/gi,'');
	var shopId="";
	var param='billNo='+billNo+'&code='+code+"&dtBegin="+dtBegin+"&dtEnd="+dtEnd;
	if($("#shopIsChoosed").is(":checked")){
		shopId=$("#shopName").val();
		if(shopId!=""&&shopId!=null){
			param+="&shopId="+shopId;
		}
	}
	param+="&downType=4"
	window.location.href="../csvdown/down/csv/down?"+param

}
</script>
</head>

<body>
<div id="yinying"></div>
<div id="shopShow" class="hideDiv">
  <div style="float:right;margin-bottom:5px;width:20px;height:20px;line-height:20px;text-align:center;background-color:#eee;margin-bottom:5px;border:1px solid #ccc;" > <span style="cursor: pointer;font-size: 14px;" onclick="closeShopShow();" >X</span> </div>
  <div class="bottom_search">
    <div class="serWrapper"><input type="text" id="searchName" class="txt"><strong class="refresh" onclick="$('#searchName').val('')">清空</strong></div>
    <input type="button" style="width:auto;margin-left:5px;" value="查询" onclick="search2()" class="common_btn">
  </div>
  <table   id="shopList" cellpadding="4" cellspacing="0" border="1" width="100%">
    <thead>
      <tr>
        <th>店面ID</th>
        <th>店面名称</th>
        <th>电话</th>
        <th>操作</th>
      </tr>
    </thead>
  </table>
  <div id="shopPager"></div>
</div>
<!-- InstanceBeginEditable name="EditRegion3" --> 
<script type="text/javascript" src="../js/doubleDate2.0.js"></script> 
<script type="text/javascript">
$(function(){
	refreshInput($(".serWrapper"));
	$('.doubledate').kuiDate({
		className:'doubledate',
		isDisabled: "1"  // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
	});

});
</script>
<div class="container" id="container">
  <div class="container_R fr">
    <div class="place">储值明细</div>
    <div class="member_search">
      <p><span>
        <input type="checkbox" id="shopIsChoosed"  style="width:auto;height:auto;border:none;">
        店面：</span>
        <select id="shopName" onclick="showShopList()" class="shopName" style=";height:20px;width: 150px;" disabled="disabled">
        </select>
        <span>起始日期：</span>
        <input type="text" readonly class="doubledate ipticon"  id="dtBegin"/>
        <span>截止时间：</span>
        <input type="text" readonly class="doubledate ipticon" id="dtEnd"/>
      </p>
      <p>
        <span>会员卡号：</span>
        <input type="text" id="code" class="absoluteTxt">
      <span>单号</span>
      <input type="text" id="billNo" class="absoluteTxt" > 
      <span>手机</span>
      <input type="text" id="mp" class="absoluteTxt" >
      </p>
      <p style="height: 20px;">      <input style="float: right;" type="button" value="查询" class="btn" onclick="search()">
      </p>
    </div>
    <table width="100%" class="member_list" cellpadding="0" cellspacing="1" border="0" id="memberList">
      <caption>
      <strong>储值列表 <span id="sup">共0条</span></strong> <a href="javascript:void(0)" onclick="downRescouse()">导出数据</a>
      </caption>
      <thead>
        <tr>
         <th>店面</th>
						<th >单据号</th>
						<th >办理时间</th>
						<th >会员卡号</th>
						<th >会员姓名</th>
						<th >电话</th>
						<th >储值类型</th>
						<th >储值金额</th>
						<th >赠送金额</th>
						<th >实际金额</th>
						<th>经办人</th>
						<th >支付状态</th>
						<th >操作</th>
        </tr>
      </thead>
      <tbody id="membersDatail"></tbody>
    </table>
     <div id="NoResult"  class="Nothing" style="text-align:center;display: none;">无符合条件的数据！</div>
    <div id="sum" style="float: left;"></div>
    <div id="pager" style="float: right;"></div>
  </div>
  <div class="fc"></div>
</div>
<!-- InstanceEndEditable --> 
<script type="text/javascript" src="../js/header.js"></script> 
<script type="text/javascript" src="../js/left.js"></script> 
<script type="text/javascript" src="../js/footer.js"></script> 
<script type="text/javascript">
clearThis("absoluteTxt");
showTab(4,5);
</script>
</body>
<!-- InstanceEnd -->
</html>
